import numpy as np

def output_info_for_pef(result_path):
    npz_file = np.load(f"{result_path}/Optimization.npz")
    At = npz_file["At"]
    cstar = npz_file["cstar"]
    rho = npz_file["rho"]
    r_ref= npz_file["r_ref"][-1]
    n = npz_file["n"]
    R= npz_file["R"][-1]
    # 定义要输出的数据
    data_to_write = [
        ("At", At),
        ("cstar", cstar),
        ("rho", rho),
        ("r_ref", r_ref),
        ("n", n),
        ("R", R)
    ]

    # 写入到txt文件
    with open(f"{result_path}/pef_info.txt", "w") as f:
        for var_name, value in data_to_write:
            f.write(f"{var_name}\t{value}\n")
